package web;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.Typeservice;
import util.web.ServletUtil;

public class AddType extends HttpServlet {

	
	
	private static final long serialVersionUID = 1L;


	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		ServletUtil.forware(request, response, "admin/addtype");
		
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		String typename = request.getParameter("typename");
		System.out.println(typename);
		boolean b = new Typeservice().addtype(typename);
		if (b) {
			
			ServletUtil.sendRedirect(response, "/admin/typelist.jspx");
		}else {
			ServletUtil.sendRedirect(response, "/admin/addtype.jspx?state=1001");
		}
		
		
		
		
	}

}
